<?php
/**
 * Data Engine 
 * File
 * @author	zhangjian<smile_for_life@sina.cn>
 * @date	2014-01-14
 */
 class Engine_File implements IEngine
 {
	private $_config = array();
	
	public function __construct()
	{
	
	}
	
	public function init($config = array())
	{
		$this->_config = $config;
	}
	
	public function query($options = array())
	{
		return true;
	}
	
	/**
	 * save data ,support batch operation
	 */
	public function insert($data = array(), $options = array())
	{
		$return = false;
		
		if(is_array($data) && $data){
			foreach($data as $uri => $data_row){
				$ips = count($data_row['ip']);
				$row = "PV: [{$data_row['pv']}]\t IP: [{$ips}]\t URL: [{$uri}]" . PHP_EOL;
				file_put_contents($this->_config['Engine_File']['data_file'] , $row, FILE_APPEND);
				$return = true;
			}
		}
		
		return $return;
	}
	
	public function update($data = array(), $options = array())
	{
		return true;
	}
	
	public function delete($options = array())
	{
		return true;
	}
	
 }